﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BigEnemyPlane : EnemyPlane {

	// Use this for initialization
	void Start () {
		InitPro();
		hpSlider = this.GetComponent<HPSlider> ();
		isDeath = false;
	}
	
	// Update is called once per frame
	void Update () {
		RecoverHp();
		if(target != null && target.transform.position.z == 0)
		{
			transform.up = (target.transform.position - new Vector3(transform.position.x, transform.position.y, 0)).normalized;
			transform.position = Vector3.MoveTowards(transform.position, target.transform.position, speed * Time.deltaTime);
		}
	}

	private void InitPro()
	{
		type = EnemyPlane.Type_BigEnemyPlane;
		hp = 300;
		currHp = hp;
		defendPower = 5;
		defendHP = 0;
		recoverHP = 0;
		speed = 0.5f;
		resistanceLaser = 1;
		resistanceMissile = 1;
		resistanceBullet = 1;
	}

	// 设置造船技术力并且重置属性
	public void setProducePower(int producePower)
	{
		this.producePower = producePower;
		ResetProByProducePower();
	}

	private void ResetProByProducePower()
	{
		/*
		敌机属性根据producePower变化而变化
		 */
	}


	public void TakeDamage(float damage){
		if(currHp <= 0)return;
		currHp -= damage;
		hpSlider.hpSlider.value = currHp / hp;
		if(currHp <= 0)
		{
			hpSlider.hpSlider.value = 0;
			print("一个大型敌机死啦");
			Destroy(gameObject);
		}
	}
}
